#!bin/bash

psql -h localhost -U postgres -W<<EOF
	CREATE DATABASE USB;
	\c usb
	CREATE TABLE Estudiante
	(
		name varchar(32),
		lastname varchar(32),
		carnet integer not null,
		CONSTRAINT carnet_estudiante_pk
			PRIMARY KEY(carnet)
	);
	\i insert.sql;
	CREATE TABLE Paciente
	(
	  	Nro integer,
		Id integer,		
		name varchar(32),
		lastname varchar(32),
		edad integer,
		CONSTRAINT Pacientet_pk
			PRIMARY KEY(Nro, Id)
	);
	CREATE TABLE Preparador
	(
	  	cedula integer,
		name varchar(32),
		lastname varchar(32),
		carnet integer,
		CONSTRAINT carnet_preparador_pk
			PRIMARY KEY(carnet)
	);
	CREATE LANGUAGE plpgsql;
	\q
	EOF
